﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGePolyline2d : OdGeSplineEnt2d
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGePolyline2d(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGePolyline2d_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGePolyline2d obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGePolyline2d()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGePolyline2d(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdGePolyline2d() : this(GlobalsPINVOKE.new_OdGePolyline2d__SWIG_0(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePolyline2d(OdGePolyline2d source) : this(GlobalsPINVOKE.new_OdGePolyline2d__SWIG_1(OdGePolyline2d.getCPtr(source)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePolyline2d(OdGePoint2dArray fitpoints) : this(GlobalsPINVOKE.new_OdGePolyline2d__SWIG_2(OdGePoint2dArray.getCPtr(fitpoints).Handle), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePolyline2d(OdGeKnotVector knots, OdGePoint2dArray points) : this(GlobalsPINVOKE.new_OdGePolyline2d__SWIG_3(OdGeKnotVector.getCPtr(knots), OdGePoint2dArray.getCPtr(points).Handle), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePolyline2d(OdGeCurve2d crv, double approxEps) : this(GlobalsPINVOKE.new_OdGePolyline2d__SWIG_4(OdGeCurve2d.getCPtr(crv), approxEps), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public int numFitPoints()
		{
			int result = GlobalsPINVOKE.OdGePolyline2d_numFitPoints(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d fitPointAt(int fitPointIndex)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGePolyline2d_fitPointAt(this.swigCPtr, fitPointIndex), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeSplineEnt2d setFitPointAt(int fitPointIndex, OdGePoint2d point)
		{
			OdGeSplineEnt2d result = new OdGeSplineEnt2d(GlobalsPINVOKE.OdGePolyline2d_setFitPointAt(this.swigCPtr, fitPointIndex, OdGePoint2d.getCPtr(point)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePolyline2d Assign(OdGePolyline2d pline)
		{
			OdGePolyline2d result = new OdGePolyline2d(GlobalsPINVOKE.OdGePolyline2d_Assign(this.swigCPtr, OdGePolyline2d.getCPtr(pline)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
